package com.decent.ejfadmin.user.dao;

import com.decent.ejfadmin.common.bean.Page;
import com.decent.ejfadmin.common.bean.UserFeedback;
import com.decent.ejfadmin.user.dao.provider.UserFeedbackDaoProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 会员意见反馈
 *
 * @author weicx
 * @date 2018/08/20
 */
@Mapper
@Repository
public interface UserFeedbackDao {
    /**
     * 查询会员反馈计数
     *
     * @param userFeedback 会员意见反馈
     * @return 总数
     */
    @SelectProvider(type = UserFeedbackDaoProvider.class, method = "queryFeedbackCount")
    int queryFeedbackCount(@Param("userFeedback") UserFeedback userFeedback);

    /**
     * 分页查询会员反馈
     *
     * @param userFeedback 会员意见反馈
     * @param page         分页组件
     * @return list
     */
    @SelectProvider(type = UserFeedbackDaoProvider.class, method = "queryFeedbackPage")
    List<UserFeedback> queryFeedbackPage(@Param("userFeedback") UserFeedback userFeedback, @Param("page") Page page);

    /**
     * 修改会员反馈
     *
     * @param userFeedback     会员意见反馈
     * @return 修改行数
     */
    @Update("update yuhuang_sup_feedback set status = #{userFeedback.status},admin = #{userFeedback.admin},dealTime = now()," +
            "remark = #{userFeedback.remark} where id = #{userFeedback.id}")
    int modifyFeedback(@Param("userFeedback") UserFeedback userFeedback);

}
